home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / MorphOS / Epic4_mos / share / epic / script / repeat < prev    next >
Encoding:
Text File  |  2002-10-28  |  1.8 KB  |  104 lines

  1. /*
  2.  * Repeat -- a zillion and one ways to do the classic alias...
  3.  */
  4.  
  5. /*
  6.  * REPEAT is now a built in command in EPIC3.003 and up.
  7.  * That means you dont need this script any more.
  8.  */
  9.  
  10. /*
  11.  * Post-modern format:
  12.  * Requires EPIC4-0.9.17 and up
  13.  * Method: Iterative loop
  14.  * Can be called recursively?  Yes. (/for uses local variables)
  15.  */
  16. : alias repeat {
  17. :    for aa from 1 to $0 { $1- }
  18. : }
  19.  
  20. /*
  21.  * Modern format:
  22.  * Requires: EPIC4pre0 and up
  23.  * Method: word-selection
  24.  * Can be called recursively?  Yes. (/fe uses local variables now)
  25.  */
  26. : alias repeat {
  27. :     fe ($jot(1 $0)) aa { $1- }
  28. : }
  29.  
  30. /*
  31.  * Modern format:
  32.  * Requires: EPIC3pre5 and up
  33.  * Method: word-selection
  34.  * Can be called recursively?  Yes. (global variables and push)
  35.  */
  36. : alias repeat {
  37. :     stack push assign aaa.r
  38. :     fe ($jot(1 $0)) aaa.r { $1- }
  39. :     stack pop assign aaa.r
  40. : }
  41.  
  42.  
  43. /*
  44.  * Modern format:
  45.  * Requires ircII2.2.9+6 and up.
  46.  * Method: word-selection
  47.  * Can be called recursively?  No. (no local variables in epic yet)
  48.  */
  49. : alias repeat fe ($jot(1 $0)) r.x {$1-}
  50.  
  51.  
  52. /*
  53.  * Modern format:
  54.  * Requires ircII2.2.9+5 and up.
  55.  * Method: iterative
  56.  * Can be called recursively?  No.
  57.  */
  58. : alias repeat for (@rx=0,$rx < [$0],@rx++) {$1-}
  59.  
  60.  
  61.  
  62. /*
  63.  * New format:
  64.  * Requires 2.2pre6 and up
  65.  * Method: iterative
  66.  * Can be called recursively?  No.
  67.  */
  68. : alias repeat {
  69. :     @ rep.cnt = [$0]
  70. :     while ( rep.cnt > 0 )
  71. :     {
  72. :         $1-
  73. :         @rep.cnt = rep.cnt - 1
  74. :     }
  75. :     ^assign -rep.cnt
  76. : }
  77.  
  78.  
  79. /*
  80.  * New format:
  81.  * Requires 2.2pre6 and up
  82.  * Method: recursion
  83.  * Can be called recursively? Yes.
  84.  */
  85. : alias repeat {
  86. :     if ([$0] > 0)
  87. :     {
  88. :         $1-
  89. :         repeat ${[$0]-1} $1-
  90. :     }
  91. : }
  92.  
  93.  
  94. /*
  95.  * Old format:
  96.  * Requires 2.2pre5 or older.
  97.  * Method: Iterative
  98.  * Can be called recursively?  No.
  99.  */
  100. : alias repeat ^assign repcnt $0;while "$repcnt>$0" "decrement $1-";^assign -repcnt
  101. : alias decrement $*;^assign repcnt ${$repcnt-1}
  102.  
  103. #hop'96
  104.